Repository navigation
feat: stream compilation output to browser via SSE (#49) - #50
Merged
Merged
Conversation
Add Server-Sent Events (SSE) endpoint to the Rust HTTP server so the browser loading page shows live compilation output instead of just a spinner. Rust server (server.rs): - Add /build-stream SSE endpoint backed by tokio::sync::broadcast - AppState gains optional broadcast::Sender<String> for SSE fan-out - start_server() accepts optional broadcast sender (None for --serve-dir) - Loading page now uses EventSource for real-time log streaming, with polling fallback for older browsers CLI (main.rs): - Create broadcast channel in compile_and_serve() - New run_python_compile_streaming() captures Python subprocess output line-by-line via piped stdout/stderr, tees each line to both the terminal and the SSE broadcast channel - Status events (compiling/success/error) sent through SSE Tests: - test_sse_endpoint_streams_events: verifies SSE data arrives correctly - test_sse_returns_404_without_broadcast: verifies --serve-dir mode - test_loading_page_contains_eventsource: verifies loading page JS
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EventSourceto subscribe to/build-stream, with polling fallbackWhat changed
Rust server (
server.rs)/build-streamSSE endpoint backed bytokio::sync::broadcastAppStategains optionalbroadcast::Sender<String>for SSE fan-outstart_server()accepts optional broadcast sender (Nonefor--serve-dirmode)EventSourcefor real-time log streaming, falls back to pollingCLI (
main.rs)compile_and_serve()creates a broadcast channel and passes it to the serverrun_python_compile_streaming()captures subprocess output viaStdio::piped(), reads line-by-line withBufReader, tees to terminal + SSE broadcastbuild-status.jsonand SSEDependencies
tokio-stream(withsyncfeature) forBroadcastStreamTest plan
cargo test -p fastled-cli— 58 tests pass (3 new SSE tests)bash lint— all checks passbash test— 119 Python tests pass